# -*- coding: utf-8 -*-

from public_util.util.AutoUrl import Route
from django.shortcuts import render_to_response
from package.models import Branch, Task, Channel


@Route()
def log_detail(request):
    """日志展示页"""
    err_msg = ""
    model = request.REQUEST.get("model")
    o_id = request.REQUEST.get("id")
    if model == "task":
        obj = Task.objects.filter(id=o_id).first()
    elif model == "branch":
        obj = Branch.objects.filter(id=o_id).first()
    elif model == "prev_branch":
        obj = Branch.objects.filter(id=o_id).first().prev_branch
    elif model == "channel":
        obj = Channel.objects.filter(id=o_id).first()
    else:
        err_msg = "model参数错误！"
        return render_to_response("feedback.html", locals())
    log_url = obj.log_url
    return render_to_response("log/log_view.html", locals())
